import { ref } from 'vue'
import { defineStore } from 'pinia'
import axios from 'axios'

export const useJokerStore = defineStore('joker', () => {
  const joke = ref('狐狸很容易摔跤，因为狡猾')
  //每隔1s刷新一个笑话
  const refreshJoker = async () => {
    const res = await axios.get('https://api-vue-base.itheima.net/api/joke')
    joke.value = res.data
  }

  return { joke, refreshJoker }
})
